package cn.jsj.finance.bank;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

 public class AddBankAccount extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
	 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("添加银行帐信息！！！");

		 //获得参数
		 cn.jsj.pojo.TblBankAccount tba=new cn.jsj.pojo.TblBankAccount();

		 String bankBreif=request.getParameter("bankBrief");
		 //换掉换行
		 bankBreif=bankBreif.replaceAll("\n", "，");
		 tba.setBankAccBrief(bankBreif);
		 tba.setBankAccTime(cn.jsj.utils.TimeDispose.transferDate(request.getParameter("bankAccTime").trim()));
		 tba.setIncomeMoney(Integer.parseInt(request.getParameter("bankIncome").trim()));
		 tba.setPayoutMoney(Integer.parseInt(request.getParameter("bankPayout").trim()));

		 //保存银行帐信息
		 cn.jsj.dao.TblBankAccountDAO tbad=new cn.jsj.dao.TblBankAccountDAO();
		 int saveResult=tbad.saveBankInfo(tba);

		 //调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("银行帐保存结果-------->"+saveResult);

		 //输出流
		  java.io.PrintWriter out=response.getWriter();
		 //如果保存成功
		 if(saveResult==1){
			 out.println("{message:'保存成功！'}");
		 }else{
			 out.println("{message:'保存失败！'}");
		 }
		 out.flush();
		 out.close();
	 }
}